package com.hmxx.myblogproject.config;


import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.util.ResourceUtils;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @description:
 * @Author: {27106}
 * @Date: {2021/11/19 13:07}
 */
@Configuration
public class MyWebMvcConfiguration implements WebMvcConfigurer {
    @Value("${uploadPathImg}")
    private String uploadPathImg;

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {

        //重写方法
        //修改tomcat 虚拟映射
        registry.addResourceHandler("/images/**")
                .addResourceLocations("file:"+uploadPathImg);//定义图片存放路径
    }
}
